var unbindData = {};
var unbindTable;

// ===================================================

$(".searchBtn1").click(function() {
	var con = $("#search1").val();

	unbindData.con = con;
	var val = $("#clickId").val();
	if (val == '') {
		val = '0';
	}
	alert(con + "," + val);
	unbindData.key = val;
	var ownAttr = $("#ownAttr").val();
	if (ownAttr == undefined || '' == ownAttr) {
		ownAttr = 'root';
	}
	unbindData.attr = ownAttr;
	unbindTable.draw();
});
$(".resetBtn1").click(function() {
	$("#search1").val('');
	var val = $("#clickId").val();
	if (val == '') {
		val = '0';
	}
	unbindData.key = val;
	unbindData.con = '';
	var ownAttr = $("#ownAttr").val();
	if (ownAttr == undefined || '' == ownAttr) {
		ownAttr = 'root';
	}
	unbindData.attr = ownAttr;
	unbindTable.draw();
});
// =========================================================
function showUnbindPart(id, ar) {
	if (ar == 'part') {
		
		return false;
	}
	// 搜索框
	var con = $("#search1").val();
	unbindData.con = con;
	unbindData.key = id;
	unbindData.attr = ar;
	unbindTable = $('#unbindPart')
			.DataTable(
					{
						"serverSide" : true,
						"ordering" : false,
						"ajax" : {
							"dataType" : "json",
							"type" : "post",
							"cache" : false,
							"url" : window.rootPath + '/ui/dgp/showUnbindPart',
							"data" : function(d) {
								return $.extend({}, d, unbindData);
							}
						},
						columns : [ {
							data : null,
							defaultContent : ""
						}, {
							data : "partName",
						}, {
							data : 'partIdentify',
						}, {
							data : 'gridAreaInfo.gridName'
						}, {
							data : 'part.partType.title'
						} ],
						"drawCallback" : function(oSettings) {
							var k = 0;
							var total = oSettings.aiDisplay.length
									+ oSettings._iDisplayStart;
							for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
								$(
										'td:eq(0)',
										oSettings.aoData[oSettings.aiDisplay[k]].nTr)
										.text(i + 1);
								k++;
							}
							unbindTable.off('click', 'tr');

						}
					});
	unbindTable.draw();
}